home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
HyperCard
/
PrintEnvelope XCMD
/
PrintEnvelope.p
next >
Wrap
Text File
|
1992-06-05
|
2KB
|
90 lines
unit upw;
interface
uses
Printing, HyperXCmd;
procedure main (paramPtr: XCmdPtr);
implementation
procedure main (paramPtr: XCmdPtr);
var
fn: Str255;
fte: TEHandle;
i: integer;
fp: PicHandle;
theEvent: EventRecord;
a, c, o: boolean;
hPrint: THPrint;
pPrPort: TPPrPort;
prStatus: TPrStatus;
gp: GrafPtr;
begin
GetPort(gp);
hPrint := THPrint(Get1Resource('PREC', 2610));
a := hPrint = nil;
PrOpen;
if a then
begin
hPrint := THPrint(NewHandle(sizeof(TPrint)));
PrintDefault(hPrint);
o := true
end
else
begin
c := EventAvail(0, theEvent);
c := PrValidate(hPrint) or (BitAnd(theEvent.modifiers, optionKey) <> 0);
o := c
end;
if o then
if PrStlDialog(hPrint) then
if PrJobDialog(hPrint) then
o := false;
if not o then
begin
pPrPort := PrOpenDoc(hPrint, nil, nil);
PrOpenPage(pPrPort, nil);
SetPort(@pPrPort^.gPort);
for i := 1 to paramPtr^.paramCount do
begin
ZeroToPas(paramPtr, Handle(paramPtr^.params[i])^, fn);
fte := GetFieldTE(paramPtr, false, 0, 0, @fn);
if fte <> nil then
begin
fte^^.inPort := @pPrPort^.gPort;
TEUpdate(pPrPort^.gPort.portRect, fte);
fp := PicHandle(GetNamedResource('PICT', fn));
if fp <> nil then
begin
DrawPicture(fp, fte^^.viewRect);
ReleaseResource(Handle(fp))
end;
TEDispose(fte)
end
end;
PrClosePage(pPrPort);
PrCloseDoc(pPrPort);
if (hPrint^^.prJob.bJDocLoop = bSpoolLoop) and (prError = noErr) then
PrPicFile(hPrint, nil, nil, nil, prStatus)
end;
PrClose;
if a then
if o then
DisposHandle(Handle(hPrint))
else
AddResource(Handle(hPrint), 'PREC', 2610, '')
else if c and not o then
ChangedResource(Handle(hPrint));
SetPort(gp)
end;
end.